"""
Case Type   : 系统内部使用工具
Case Name   : 使用gs_ctl工具gs_ctl的版本信息然后退出
Create At   : 2021/01/15
Owner       : opentestcase015
Description :
    1.使用gs_ctl工具打印版本信息
Expect      :
    1.使用gs_ctl工具打印版本信息成功
History     :
"""

import unittest

from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger
from yat.test import Node
from yat.test import macro

LOG = Logger()


class SystemInternalTools(unittest.TestCase):
    def setUp(self):
        LOG.info('-------------------this is setup------------------')
        LOG.info('---Opengauss_Function_Tools_gs_ctl_Case0111开始执行-----')
        self.constant = Constant()
        self.user_node = Node('dbuser')
        self.user_node = Node('PrimaryDbUser')

    def test_system_internal_tools(self):
        LOG.info('--------------------查看版本信息--------------------')
        excute_cmd = f'''
            source {macro.DB_ENV_PATH};
            gs_ctl -V;
            '''
        LOG.info(excute_cmd)
        msg = self.user_node.sh(excute_cmd).result()
        LOG.info(msg)
        self.assertIn(self.constant.opengauss, msg)

    def tearDown(self):
        LOG.info('-------------this is tearDown----------------')
        # 无需清理环境
        LOG.info('-----Opengauss_Function_Tools_gs_ctl_Case0111执行完成---')
